package net.qhzw.admin.service;

import net.qhzw.admin.domain.UserDto;
import net.qhzw.admin.entity.SysUser;
import net.qhzw.admin.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;


@Service
public class UmsAdminService {


    @Autowired
    private SysUserMapper userMapper;


    public UserDto loadUserByUsername(String username){
        UserDto userDto = new UserDto();
        SysUser user = userMapper.selectByUsername(username);
        if (user == null){
            return null;
        }
        userDto.setNickName(user.getNickName());
        userDto.setUsername(user.getUsername());
        userDto.setId(user.getId());
        userDto.setPassword(user.getPassword());
        userDto.setStatus(user.getStatus());
        //userDto.setRoles(Arrays.asList("admin"));
        return userDto;
    }
}
